#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    // 总长12
    Buffer *buffer = app_buffer_init(12);

    // 1.写入abcd     abcd                    offset=0
    // 2.写入efghi    abcd efghi                     0
    // 3.读取abcd     abcd efghi(读 但是不删除)        4
    // 4.写入jklmno   mnod efghi jkl                 4
    // 5.读取efghi    mnod efghi jkl                 9
    // 6.读取jklmno   mnod efghi jkl                 3

    app_buffer_write(buffer, "abcd", 4);  // 1
    app_buffer_write(buffer, "efghi", 5); // 2

    char data1[4];
    app_buffer_read(buffer, data1, 4);     // 3
    app_buffer_write(buffer, "jklmno", 6); // 4

    char data2[5];
    app_buffer_read(buffer, data2, 5); // 5

    char data3[6];
    app_buffer_read(buffer, data3, 6); // 6

    // 释放
    app_buffer_free(buffer);

    return 0;
}
